package me.hunche.app.service.impl;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

import me.hunche.app.service.SMSService;
import me.hunche.app.sms.SMSHandler;
import me.hunche.app.vo.ShortMessage;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.hp.hpl.helper.misc.DateHelper;

//@Service
public class SMSServiceDummyImpl implements SMSService{
	
	private static final Logger logger = Logger.getLogger(SMSServiceDummyImpl.class);

	
//	@Override
	public void sendMessage(List<String> recipients, String content) {
		StringBuffer smsMob = new StringBuffer();
		for(String r:recipients){
			smsMob.append(r);
			smsMob.append(",");
		}
		
		smsMob.deleteCharAt(smsMob.length()-1);
		sendMessage(smsMob.toString(),content);
	}

	public void sendMessage(String[] recipients, String content) {
		
		StringBuffer smsMob = new StringBuffer();
		for(String r:recipients){
			smsMob.append(r);
			smsMob.append(",");
		}
		
		smsMob.deleteCharAt(smsMob.length()-1);
		sendMessage(smsMob.toString(),content);
	}
	
	public void sendMessage(String smsMob,String content) {
		if (logger.isDebugEnabled()) {
			logger.debug("sendMessage recipients=" + smsMob + ",content=" + content);
		}
	}

	public List<ShortMessage> receive() {
		// TODO Auto-generated method stub
		return null;
	}

	public void registerHandler(SMSHandler handler, String prefix) {
		// TODO Auto-generated method stub
		
	}

	public void registerHandler(SMSHandler handler) {
		// TODO Auto-generated method stub
		
	}

	public void sendScheduledMessage(List<String> recipients, String content,
			Date sendTime) {
		if (logger.isDebugEnabled()) {
			logger.debug("sendScheduledMessage recipients=" + Arrays.toString(recipients.toArray()) + ",content=" + content +",sendTime="+DateHelper.toString(sendTime, "yyyy-MM-dd HH:mm:ss"));
		}
	}

	public void sendScheduledMessage(String recipient, String content,
			Date sendTime) {
		if (logger.isDebugEnabled()) {
			logger.debug("sendScheduledMessage recipient=" + recipient + ",content=" + content +"("+content.length()+"),sendTime="+DateHelper.toString(sendTime, "yyyy-MM-dd HH:mm:ss"));
		}
	}

}
